package my.bc.webdav.client.test;

import java.util.List;

import my.bc.webdav.client.DavManager;
import my.bc.webdav.client.DavSession;
import my.bc.webdav.client.ServerInfo;
import my.bc.webdav.model.DavNode;

import org.junit.Before;
import org.junit.Test;

public class DavSessionTester
{
  private ServerInfo serverInfo;
  private DavSession session;

  @Before
  public void prepare()
  {
    serverInfo = new AlfrescoServer();
    
    DavManager davManager = new DavManager( serverInfo );
    session = davManager.newSession();
  }

  @Test
  public void testCase()
  {
    //isFoldTest();
    getSkeletonsTest();
  }

  public void isFoldTest()
  {
    String[] paths = new String[]{ "MarketingGraphics/documentLibrary/MARKETING%20ASSETS/PRODUCT%20DESIGN/Fortinet%20iPhone%20App/Fortinet%20App%20Icon%20%5BRounded%5D/Icon-Small@2x.png/" };
    for( String path : paths )
    {
      try
      {
        System.out.println( path + " is a fold: " + session.isFold( path ) );
      }
      catch( Exception e )
      {
        e.printStackTrace();
      }
    }
  }
  
  public void getSkeletonsTest()
  {
    try
    {
//      final String relativePath = "MarketingGraphics/documentLibrary/MARKETING%20ASSETS/CAMPAIGNS/Gartner%202014/Gartner%20Fortini’s%20On%20Us%20sign";
      final String relativePath = "MarketingGraphics/documentLibrary/MARKETING%20ASSETS/CAMPAIGNS/Gartner%202014/Gartner%20Fortini's%20On%20Us%20sign";
      List<DavNode> nodes = session.getSkeletons( relativePath, true, false );
    }
    catch( Exception e )
    {
      e.printStackTrace();
    }
  }
}
